class DataIndex(object):
    def __init__(self, tid=0, index=-1, title_id="", title="", title_type="", sys_type="", name="", value="", is_jump="",
                 jump_to="", req="", is_text=False, relation="", options=None, children=None, min_oper_num=0,
                 max_oper_num=0, valid_values=None, **kwargs):
        """
        :param tid: 当前是第几题（本系统编号，从1开始的正整数）
        :param index: 数据库中的下标，-1表示下标获取失败
        :param title_id: 当前是第几题
        :param title: 标题
        :param is_jump: 是否跳题
        :param jump_to: 跳到哪一题
        :param req: 是否必选
        :param relation: 依赖哪一题
        :param title_type: 题目类型
        :param sys_type: 系统中的题目类型
        :param name: 选项
        :param value: 值
        :param is_text: 是否填空题
        :param options: 选项
        :param children: 子题目
        :param min_oper_num: 最小值
        :param max_oper_num: 最大值
        :param valid_values: 合法参数
        """
        self.tid = tid or 0
        self.index = index
        self.title_id = title_id or ""
        self.title = title or ""
        self.title_type = title_type or ""
        self.sys_type = sys_type or ""
        self.name = name or ""
        self.value = value or ""
        self.is_jump = is_jump or ""
        self.jump_to = jump_to or ""
        self.req = req or ""
        self.is_text = is_text or False
        self.relation = relation or ""
        self.min_oper_num = min_oper_num or ""
        self.max_oper_num = max_oper_num or ""
        self.options = options or []
        self.children = children or []
        self.valid_values = valid_values


class ItemWjxOb(object):

    def __init__(self, tid=0, title_id=-1, title="", title_type="", sys_type="", name="", value="", is_jump="", jump_to="",
                 req="", is_text=False, relation="", options=None, children=None, min_oper_num=None, max_oper_num=None,
                 rate=0, text="", is_reverse=False, data_index=None, is_repeat=False, sys_scheme=None,
                 sys_relation=None, rl_value="", page_id=""):
        """
        :param tid: 当前是第几题（本系统编号，从1开始的正整数）
        :param title_id: 当前是第几题（问卷星题号）
        :param title: 标题
        :param is_jump: 是否跳题
        :param jump_to: 跳到哪一题
        :param req: 是否必选
        :param relation: 依赖哪一题
        :param title_type: 题目类型
        :param sys_type: 系统中的题目类型
        :param name: 选项
        :param value: 值
        :param is_text: 是否填空题
        :param options: 选项
        :param children: 子题目
        :param min_oper_num: 最小值
        :param max_oper_num: 最大值
        :param rate: 生成比例
        :param text: 生成文本
        :param is_reverse: 是否反转
        :param is_repeat: 是否去重
        :param sys_scheme: 系统的方案数组
        :param sys_relation: 系统的相关题目数组
        :param data_index: 这道题的数据库索引列表 -> []
        :param rl_value: 真实值
        :param page_id: 页码ID（腾讯问卷提交问卷时用）
        """
        self.tid = tid or 0
        self.title_id = title_id or ""
        self.title = title or ""
        self.title_type = title_type or ""
        self.sys_type = sys_type or ""
        self.name = name or ""
        self.value = value or ""
        self.is_jump = is_jump or ""
        self.jump_to = jump_to or ""
        self.req = req or ""
        self.is_text = is_text or False
        self.relation = relation or ""
        self.min_oper_num = min_oper_num or 0
        self.max_oper_num = max_oper_num or 0
        self.rate = rate or 0
        self.text = text
        self.is_reverse = is_reverse
        self.options = options or []
        self.children = children or []
        self.data_index = data_index
        self.is_repeat = is_repeat
        self.sys_scheme = sys_scheme
        self.sys_relation = sys_relation
        self.rl_value = rl_value
        self.page_id = page_id


class ItemProgrammeObject(object):

    def __init__(self, id="", title_id=-1, title="", title_type="", sys_type="", name="", value="", is_jump="",
                 jump_to="", req="", is_text=False, relation="", options=None, children=None, min_oper_num=None,
                 max_oper_num=None, rate=0, text="", is_reverse=False, data_index=None, is_repeat=False, score=100,
                 checked=[], uuid="", type=0, type_name=""):
        """
        :param title_id: 当前是第几题
        :param title: 标题
        :param is_jump: 是否跳题
        :param jump_to: 跳到哪一题
        :param req: 是否必选
        :param relation: 依赖哪一题
        :param title_type: 题目类型
        :param sys_type: 系统中的题目类型
        :param name: 选项
        :param value: 值
        :param is_text: 是否填空题
        :param options: 选项
        :param children: 子题目
        :param min_oper_num: 最小值
        :param max_oper_num: 最大值
        :param rate: 生成比例
        :param text: 生成文本
        :param is_reverse: 是否反转
        :param is_repeat: 是否去重
        :param score: 权重, 权重默认是100
        :param checked: 已经选择的选项
        :param uuid: 当前唯一key
        :param type:  前端冗余字段，用处不详
        :param type_name:  前端冗余字段，用处不详
        :param data_index: 这道题的数据库索引列表 -> []
        """
        self.id = id
        self.title_id = title_id or ""
        self.title = title or ""
        self.title_type = title_type or ""
        self.sys_type = sys_type or ""
        self.name = name or ""
        self.value = value or ""
        self.is_jump = is_jump or ""
        self.jump_to = jump_to or ""
        self.req = req or ""
        self.is_text = is_text or False
        self.relation = relation or ""
        self.min_oper_num = min_oper_num or 0
        self.max_oper_num = max_oper_num or 0
        self.rate = rate or 0
        self.text = text
        self.is_reverse = is_reverse
        self.options = options or []
        self.children = children or []
        self.data_index = data_index
        self.is_repeat = is_repeat
        self.score = score
        self.checked = checked
        self.uuid = uuid
        self.type = type
        self.type_name = type_name


class GenerateObj(object):

    def __init__(self, title_id=-1, title="", title_type="", sys_type="", name="", value="", is_jump="", jump_to="",
                 req="", is_text=False, relation="", options=None, children=None, min_oper_num=None, max_oper_num=None,
                 rate=0, text="", is_reverse=False, data_index=None, is_repeat=False, sys_scheme=None,
                 sys_relation=None,
                 # uuid="", type=None, type_name="", prate=0
                 ):
        """
        :param title_id: 当前是第几题
        :param title: 标题
        :param is_jump: 是否跳题
        :param jump_to: 跳到哪一题
        :param req: 是否必选
        :param relation: 依赖哪一题
        :param title_type: 题目类型
        :param sys_type: 系统中的题目类型
        :param name: 选项
        :param value: 值
        :param is_text: 是否填空题
        :param options: 选项
        :param children: 子题目
        :param min_oper_num: 最小值
        :param max_oper_num: 最大值
        :param rate: 生成比例
        :param text: 生成文本
        :param is_reverse: 是否反转
        :param is_repeat: 是否去重
        :param sys_scheme: 系统的方案数组
        :param sys_relation: 系统的相关题目数组
        # :param uuid: 前端冗余字段, 用处不详, 当前唯一key
        # :param type:  前端冗余字段, 用处不详
        # :param type_name:  前端冗余字段, 用处不详
        # :param prate:  前端冗余字段, 百分比的比例
        :param data_index: 这道题的数据库索引列表 -> []
        """
        self.title_id = title_id or ""
        self.title = title or ""
        self.title_type = title_type or ""
        self.sys_type = sys_type or ""
        self.name = name or ""
        self.value = value or ""
        self.is_jump = is_jump or ""
        self.jump_to = jump_to or ""
        self.req = req or ""
        self.is_text = is_text or False
        self.relation = relation or ""
        self.min_oper_num = min_oper_num or 0
        self.max_oper_num = max_oper_num or 0
        self.rate = rate or 0
        self.text = text
        self.is_reverse = is_reverse
        self.options = options or []
        self.children = children or []
        self.data_index = data_index
        self.is_repeat = is_repeat
        self.sys_scheme = sys_scheme
        self.sys_relation = sys_relation
        # self.uuid = uuid
        # self.type = type
        # self.type_name = type_name
        # self.prate = prate

    @staticmethod
    def conver_json_2_obj(json_obj):
        generate_obj = GenerateObj()  # 创建 GenerateObj 实例
        for field, value in json_obj.items():  # 遍历所有字段
            setattr(generate_obj, field, value)
        return generate_obj
